package com.id_dactylogram.units;

import org.apache.zookeeper.common.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class BioServer {

    public void run(int port) throws IOException {
        ServerSocket serverSocket = new ServerSocket(port);
        Socket socket = serverSocket.accept();
        System.out.println("获取到链接：" + socket.getInetAddress());
        while (true) {
            InputStream is = socket.getInputStream();
            byte[] readBuf = new byte[1024];
            int len;
            while ((len = is.read(readBuf)) > 0) {
                System.out.println(new String(readBuf, 0, len));
            }
            is.close();
        }
    }
}
